<template>
  <a-button
    :size="size"
    :ghost="!!type && type != 'primary' && type != 'default'"
    :type="type == 'danger' ? 'primary' : type"
    :disabled="disabled"
    @click="clickCallback"
  >
    <template #icon>
      <span
        v-if="['gctbaocun1', 'gctfuzhi'].includes(icon)"
        class="icon gcticons"
        :class="[icon]"
      ></span>
      <svg v-else-if="icon" class="icon gcticons" aria-hidden="true">
        <use :xlink:href="'#' + icon"></use>
      </svg>
    </template>
    {{ text }}
  </a-button>
</template>

<script>
  export default {
    name: 'g-btn',
    props: {
      size: {
        default: 'default',
      },
      type: {
        default: 'default',
      },
      text: {},
      disabled: { default: false },
      icon: {},
      eventName: {},
    },
    data() {
      return {};
    },
    created() {},
    methods: {
      clickCallback(e) {
        this.$emit('callback', this.eventName);
        // 阻止form提交
        e.preventDefault();
        e.stopPropagation();
        return false;
      },
    },
  };
</script>

<style scoped></style>
